{extend name="common/base"}
{block name='title'}优惠券编辑页面{/block}
{block name='body-type'}coupon_edit{/block}
{block name="content"}
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">


                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">编辑优惠券</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form enctype="multipart/form-data" class="am-form tpl-form-border-form tpl-form-border-br" action="{:Url('admin/coupon/update')}?id={$result.id}" method="post">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵名称 </label>
                                        <div class="am-u-sm-9">
                                            <input type="text" name="coupon_name" class="tpl-form-input" id="user-name" placeholder="请输入优惠劵名称" value="{$result.coupon_name}">
                                        </div>
                                    </div>
                                    
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵金额 </label>
                                        <div class="am-u-sm-9">
                                            <input type="text" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"  name="coupon_money" class="tpl-form-input" id="" placeholder="请输入优惠劵金额" value="{$result.coupon_money}">
                                            <small>只能填写数字/小数点</small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">使用最小金额 </label>
                                        <div class="am-u-sm-9">
                                            <input type="text" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"  name="min_amount" class="tpl-form-input" id="" placeholder="请输入使用最小金额" value="{$result.min_amount}">
                                            <small>只能填写数字/小数点</small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">使用最大金额 </label>
                                        <div class="am-u-sm-9">
                                            <input type="text" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"  name="max_amount" class="tpl-form-input" id="" placeholder="请输入使用最大金额" value="{$result.max_amount}">
                                            <small>只能填写数字/小数点</small>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵发送起始时间</label>
                                        <div class="am-u-sm-9">
                                            <input type="date" name="send_start_time" class="tpl-form-input" id="" placeholder="请输入优惠劵领取起始时间" value="{$result.send_start_time}">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵发送截止时间</label>
                                        <div class="am-u-sm-9">
                                            <input type="date" name="send_end_time" class="tpl-form-input" id="" placeholder="请输入优惠劵发送截止时间" value="{$result.send_end_time}">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵使用起始时间</label>
                                        <div class="am-u-sm-9">
                                            <input type="date" name="use_start_time" class="tpl-form-input" id="" placeholder="优惠劵使用起始时间" value="{$result.use_start_time}">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">优惠劵使用截止时间</label>
                                        <div class="am-u-sm-9">
                                            <input type="date" name="use_end_time" class="tpl-form-input" id="" placeholder="优惠劵使用截止时间" value="{$result.use_end_time}">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-intro" class="am-u-sm-3 am-form-label">优惠券描述</label>
                                        <div class="am-u-sm-9">
                                            <textarea class="" rows="5" id="user-intro" name="coupon_data" placeholder="请输入优惠券描述">{$result.coupon_data}</textarea>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
        </div>
        {/block}
        {block name="footer-js"}
        <script>
            function upimg(obj)
          {
            if( obj.value == "" ) {
              return;
            }
            var formdata = new FormData(); 
            formdata.append("src" , $(obj)[0].files[0]);//获取文件法二
            $.ajax({
              type : 'post',
              url : "{:Url('admin/ad/upimg')}",
              data : formdata,
              cache : false,
              processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
              contentType : false, // 不设置Content-type请求头
              success : function(ret){
                $('#img-view-box').attr('src', ret.src);
                $('#img-value-box').val(ret.src);
                $('#thumb-img-value-box').val(ret.thumb_src);

                  //alert(obj.value);
              },
              error : function(){ }
            });
          }   
        </script>
        {/block}